<template>
    <div :class="{ 'app-header--sticky': isSticky }">这是一个吸顶效果的头部</div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        isSticky: false
      };
    },
    mounted() {
      window.addEventListener('scroll', this.handleScroll);
    },
    beforeDestroy() {
      window.removeEventListener('scroll', this.handleScroll);
    },
    methods: {
      handleScroll() {
        if (window.scrollY > 80) {
          this.isSticky = true;
        } else {
          this.isSticky = false;
        }
      }
    }
  };
  </script>
  
  <style>
  .app-header--sticky {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: #fff;
    /* 其他样式 */
  }
  </style>